home *** CD-ROM | disk | FTP | other *** search
Gui4CLI script | 1980-01-03 | 6.3 KB | 214 lines |
- G4C
-
- ; Palette.gc by dck/J.Collett
-
- ; A full palette gui with many capabilities
- ; Press CONTROL-J to make it jump screens
-
- winbig -1 -1 235 120 'Palette'
- wintype 11110001
- varpath '' ; we only need our private vars
-
- box 0 0 0 0 out icondrop
-
- xonload
- guiopen palette.gc
- info palette palette.gc/5 ; get info on *our* platte
- setvar type 'update'
- gosub palette.gc update ; Subroutine
-
- xonRMB ; on rmb we update to the color under mouse position
- update palette.gc 5 $$mouse.color
- gosub palette.gc update ; did not choose the color by clicking it
-
-
- xonclose
- ; ---- If Ram:Spr was created, delete it
- ifexists FILE Ram:Spr.rexx
- delete Ram:Spr.rexx
- endif
- guiquit palette.gc
-
- xpalette 10 5 225 30 ; This is the visible palette
- gadid 5
- gosub palette.gc $type
-
- xHSlider 40 40 160 12 R pal.r 0 15 0 %2ld
- setcolor palette.gc $$color.num $pal.r $pal.g $pal.b
- gadid 1
-
- xHSlider 40 52 160 12 G pal.g 0 15 0 %2ld
- setcolor palette.gc $$color.num $pal.r $pal.g $pal.b
- gadid 2
-
- xHSlider 40 64 160 12 B pal.b 0 15 0 %2ld
- setcolor palette.gc $$color.num $pal.r $pal.g $pal.b
- gadid 3
-
-
- ; --- routine to update sliders & get variables
-
- xRoutine update
- pal.r = $$color.r ; get new values Three colour values, the
- ; colour number, and the total number of colours.
- pal.g = $$color.g
- pal.b = $$color.b
- pal.n = $$color.num
- pal.t = $$color.total
- pal.or = $pal.r ; store values for undo slider changes
- pal.og = $pal.g ; original rgb values
- pal.ob = $pal.b
- update palette.gc 1 $pal.r ; Update gads 1, 2, 3
- update palette.gc 2 $pal.g
- update palette.gc 3 $pal.b
- setwintitle palette.gc 'Palette color $pal.n of $pal.t'
-
-
- ; -----------> buttons to save/load etc palettes (saved as guis)
-
- xbutton 10 85 70 14 Undo ; undo last changes
- setcolor palette.gc $$color.num $pal.or $pal.og $pal.ob
- gosub palette.gc update
-
-
- ; ---- Load a previously saved palette (i.e. a normal GUI with setcolors)
- ; ---- We *must* set the variable $pal.gui to the name of our gui
-
- xbutton 80 85 70 14 Load..
- pal.file = ''
- ReqFile -1 -1 300 200 'Load Palette:' LOAD pal.file 'GUIs:tools/palette'
- if $pal.file = ''
- stop
- endif
- *pal.gui = palette.gc ; set pal.gui as a GLOBAL variable
- guiload $pal.file ; load the gui
- delvar *pal.gui ; delete pal.gui as we don't need it
- update palette.gc 5 1 ; go back to color No 1
- info palette palette.gc/5 ; get info on palette
- gosub palette.gc update ; redraw the sliders etc
-
-
- ; ---- saving : make a loop and write a gui to set all colors
- ; variable pal.gui must (when loading) contain the name of the
- ; gui whose screen colors will be changed.
-
- xbutton 150 85 70 14 Save..
- pal.file = ''
- ReqFile -1 -1 300 200 'Save Palette:' SAVE pal.file ''
- if $pal.file = ''
- stop
- endif
- guiwindow palette.gc wait
- setwintitle palette.gc 'Saving Palette...'
- info palette palette.gc/5 ; make sure we're talcking about *our* palette
- setvar .palette 'G4C\n\n;Palette\n\nxOnLoad\n'
- pal.count = 0
- while $pal.count < $pal.t
- update palette.gc 5 $pal.count ; update the palette to next color
- append env:.palette 'setcolor \$pal.gui $pal.count $$color.r $$color.g $$color.b\n'
- counter pal.count inc 1
- endwhile
- extract pal.file file pal.filename
- append env:.palette 'guiquit $pal.filename\n'
- copy env:.palette $pal.file
- delete env:.palette
- guiwindow palette.gc resume
- update palette.gc 5 1
- info palette palette.gc/5
- gosub palette.gc update
-
- ; ---- JC's additions below this line : Copy, Exchange, Spread
-
- xbutton 10 100 70 14 Copy
- setvar type 'copy'
-
- xbutton 80 100 70 14 Exchange
- setvar type 'exchange'
-
- xbutton 150 100 70 14 Spread
- setvar type 'spread'
-
- ; --- routine to copy values
-
- xRoutine copy
- pal.on = $pal.n ; Store existing colour number
- pal.r = $$color.r ; get new values
- pal.g = $$color.g
- pal.b = $$color.b
- pal.n = $$color.num
- ;Set new colour to old values
- setcolor palette.gc $pal.n $pal.or $pal.og $pal.ob
- setvar type 'update' ; Reset routine flag
- ; Update window title
- setwintitle palette.gc 'Copied color $pal.on to $pal.n'
- update palette.gc 5 $pal.n
- gosub palette.gc update
-
- ; --- routine to exchange values
-
- xRoutine exchange
- pal.on = $pal.n ; Store existing colour number
- pal.r = $$color.r ; get new values
- pal.g = $$color.g
- pal.b = $$color.b
- pal.n = $$color.num
- ;Set each colour to other values
- setcolor palette.gc $pal.n $pal.or $pal.og $pal.ob
- setcolor palette.gc $pal.on $pal.r $pal.g $pal.b
- setvar type 'update' ; Reset routine flag
- ; Update window title
- setwintitle palette.gc 'Exchanged colors $pal.on and $pal.n'
- update palette.gc 5 $pal.n
- gosub palette.gc update
-
- ; --- routine to spread values
-
- xRoutine spread
- update palette.gc 5 $$color.num
- setvar CStore "$pal.n "
- appvar CStore "$$color.num "
- appvar CStore "$pal.or "
- appvar CStore "$pal.og "
- appvar CStore "$pal.ob "
- appvar CStore "$$color.r "
- appvar CStore "$$color.g "
- appvar CStore "$$color.b"
- ifexists FILE Ram:Spr.rexx
- ; nop
- else
- gosub Palette.gc MakeRexx
- rename env:.Spr Ram:Spr.rexx
- endif
- run 'sys:rexxc/rx Ram:Spr.rexx $CStore'
- setvar type 'update' ; Reset routine flag
- gosub palette.gc update
-
- ; ---- Routine to create an ARexx program to do the spreading.
-
- xroutine MakeRexx
- setvar .Spr "/* */\n"
- append Env:.Spr "parse arg col1 col2 r1 g1 b1 r2 g2 b2 \n"
- append Env:.Spr "if col1 > col2 then do\n"
- append Env:.Spr " n = col1 ; col1 = col2 ; col2 = n\n"
- append Env:.Spr " rn = r1 ; r1 = r2 ; r2 = rn\n"
- append Env:.Spr " gn = g1 ; g1 = g2 ; g2 = gn\n"
- append Env:.Spr " bn = b1 ; b1 = b2 ; b2 = bn ; end\n"
- append Env:.Spr "dif = col2 - col1 - 1\n"
- append Env:.Spr "rds = max(r1,r2) - min(r1,r2) - 1\n"
- append Env:.Spr "gds = max(g1,g2) - min(g1,g2) - 1\n"
- append Env:.Spr "bds = max(b1,b2) - min(b1,b2) - 1\n"
- append Env:.Spr "dr = sign(r2 - r1) ; dg = sign(g2 - g1)\n"
- append Env:.Spr "db = sign(b2 - b1)\n"
- append Env:.Spr "rbit = rds / dif * dr ; gbit = gds / dif * dg\n"
- append Env:.Spr "bbit = bds / dif * db\n"
- append Env:.Spr "do st = 1 to dif\n"
- append Env:.Spr " r = r1 + trunc(st * rbit)\n"
- append Env:.Spr " g = g1 + trunc(st * gbit)\n"
- append Env:.Spr " b = b1 + trunc(st * bbit)\n"
- append Env:.Spr " msg = col1 + st || ' ' r || ' ' || g || ' ' b\n"
- append Env:.Spr " address 'Gui4Cli'\n"
- append Env:.Spr " 'SetColor Palette.gc ' msg\n"
- append Env:.Spr " address\n"
- append Env:.Spr " end\n"
- append Env:.Spr "exit\n"
-